/*
 * SerializableStop.java
 * 
 * Copyright 2008 David D. Emory
 * 
 * This file is part of Five Points. See <http://www.fpdev.org> for
 * additional information regarding the project.
 * 
 * Five Points is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Five Points is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Five Points.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.fpdev.core.transit;

import java.io.Serializable;
import org.fpdev.core.basenet.BaseNetwork;

/**
 *
 * @author demory
 */
public class SerializableStop implements Serializable {

  private int nodeID_,  type_,  inPLI_,  outPLI_,  index_,  restriction_;
  private String name_;

  public SerializableStop(int nodeID, int type, String name, int inPLI, int outPLI, int index, int restriction) {
    nodeID_ = nodeID;
    type_ = type;
    name_ = name;
    inPLI_ = inPLI;
    outPLI_ = outPLI;
    index_ = index;
    restriction_ = restriction;
  }

  public int getNodeID() {
    return nodeID_;
  }

  public int getType() {
    return type_;
  }

  public int getInPLI() {
    return inPLI_;
  }

  public int getOutPLI() {
    return outPLI_;
  }

  public int getIndex() {
    return index_;
  }

  public int getRestriction() {
    return restriction_;
  }

  public Stop createStop(TransitPath tpath, BaseNetwork basenet) {
    switch (type_) {

      case Stop.STOP_BASIC:
        switch (restriction_) {
          case Stop.RESTRICTION_BOARD_ONLY:
            return new BoardOnlyStop(tpath, basenet.getNodeFromID(nodeID_), inPLI_, outPLI_);
          case Stop.RESTRICTION_ALIGHT_ONLY:
            return new AlightOnlyStop(tpath, basenet.getNodeFromID(nodeID_), inPLI_, outPLI_);
          default:
            return new BasicStop(tpath, basenet.getNodeFromID(nodeID_), inPLI_, outPLI_);
        }
      case Stop.STOP_TIMEPOINT:
        switch (restriction_) {
          case Stop.RESTRICTION_BOARD_ONLY:
            return new BoardOnlyTimePoint(tpath, basenet.getNodeFromID(nodeID_), index_, name_, inPLI_, outPLI_);
          case Stop.RESTRICTION_ALIGHT_ONLY:
            return new AlightOnlyTimePoint(tpath, basenet.getNodeFromID(nodeID_), index_, name_, inPLI_, outPLI_);
          default:
            return new TimePoint(tpath, basenet.getNodeFromID(nodeID_), index_, name_, inPLI_, outPLI_);
        }
    }
    return null;
  }
}
